package no.sachmuld.methodcombination.impl.validate;

import no.sachmuld.methodcombination.api.BehaviourMethod;

/**
 *
 */
public class IncompatibleReturnType extends MethodCombinationValidationError {

    private BehaviourMethod behaviourMethod;

    public IncompatibleReturnType(Class targetClass, BehaviourMethod behaviourMethod) {
        super(targetClass);
        this.behaviourMethod = behaviourMethod;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("Incompatible return type in method ");
        sb.append(behaviourMethod.getMethodName());
        sb.append(" in behaviour class ");
        sb.append(behaviourMethod.getBehaviourClass().getName());
        sb.append(". Expected ");
        sb.append(behaviourMethod.getReturnType().getSimpleName());
        sb.append(", found ");
        sb.append(behaviourMethod.getMethod().getReturnType().getSimpleName());
        return sb.toString();
    }
}
